<?php
//including header.php 
include '../../include/header.php';
//including page.php (It is a class which contain functions)
include '../../libraries/page.php';
$page = new page();
session_start();
$userid = $_SESSION['userid'];

// checking the session
if (!$_SESSION['username']) {
    header("location:../user/login.php");
}
if ($_GET['q'] == 'logout') {
    $page->user_logout();
    header("location:../user/login.php");
}
if ($_SERVER["REQUEST_METHOD"] == "POST") {
// for $_POST['submit'].  Remember, field names are determined by array keys!
    $result = $page->mysql_update_array("options", "1", "id", $_POST);
    if ($result) {
       $msg = $message[3];
    } else {
         $msg = $message[0];
    }
    } 
 
?>

<!-----------------------------------------------content----------------------------------->

<!-------------------------------------Navbar---------------------------------->
<?
$suppliers = 'active';
include '../../include/navbar.php';
?>


<br>

<!----------------------------------Display the result message of Update--------------------->
<div  align="center"><? echo $msg; ?></div>

<!----------------------------------------------div for placing form here------------------------->
<div>


    <!-----------------We are retrieving data from database table to display in the fields to update--------->
    <?
    //php code to get the data from options table 
    $options = mysql_query("select * from options where id = '1'");
    $options_data = mysql_fetch_array($options);

  
    ?>



    <!---------------------------------form------------------------------------------------>
    <form method="POST"  action="">
        <div class="maindiv">
            <h3 style="color:#777;text-align: center">Options</h3>
            <div class="leftdiv">
                <label>Outlet Name</label>
                <input class="input-xlarge" id="focusedInput" type="text" name="name" value="<?=$options_data['name'];?>"  required>
            </div>
            <div class="middiv"></div>
            <div class="rightdiv">  <label>Address</label>
                <input class="input-xlarge"  id="focusedInput" name="address" type="text"  value="<?=$options_data['address'];?>"  >
            </div>
            <div class="leftdiv">
                <label>Phone</label>
                <input class="input-xlarge" id="focusedInput" type="text" name="phone"  value="<?=$options_data['phone'];?>">
            </div>
            <div class="middiv"></div>
            <div class="rightdiv"> <label>Fax</label>
                <input class="input-xlarge"  id="focusedInput"  type="text" name="fax"  value="<?=$options_data['fax'];?>"  >
            </div>
            <div class="leftdiv">
                <label>TIN Number</label>
                <input class="input-xlarge"  id="focusedInput"  type="text" name="tin"  value="<?=$options_data['tin'];?>"  >
            </div>
            <div class="middiv"></div>
            <div class="rightdiv">
                <label>Email</label>
                    <input class="input-xlarge" id="inputEmail" type="email" name ="email" value="<?=$options_data['email'];?>" required >
            </div>
            <div class="leftdiv">
                <label>Owner Name</label>
                <input class="input-xlarge" id="focusedInput" type="text" name="owner" value="<?=$options_data['owner'];?>" required >
            </div>
            <div class="middiv"></div>
            <div class="rightdiv">
                <label>Discount type</label>
                <select name ="discount_type" style="width:280px">
                    <option value="amount">Amount</option>
                     <option value="percentage">Percentage</option>
                </select>
            </div>
             <div class="leftdiv">
               <label>Bill Header</label>
               <textarea rows="3" name="billheader" ><?=$options_data['billheader'];?></textarea>
            </div>
            <div class="middiv"></div>
            <div class="rightdiv"> 
                 <label>Bill Footer</label>
               <textarea rows="3" name="billfooter" ><?=$options_data['billfooter'];?></textarea>
            </div>
            <div class="fulldiv">
                <button class="btn btn-inverse" type="submit"   style="float:right; margin-right: 45px; margin-top: 20px;">Update</button> 
            </div>
        </div>

    </form>
</div>

<?php
//including footer.php
include '../../include/footer.php';
?>
